#include <iostream>
#include <algorithm>
int main(int argc, char const *argv[])
{
    int perms[10];
    int n = 10;
    for (int i = 0; i < n; i++)
    {
        perms[i] = i;
    }
    do
    {
        for (int i = 0; i < n; i++)
        {
            std::cout << perms[i] << " ";
        }
        std::cout << std::endl;
    } while (std::next_permutation(perms, perms + n));

    return 0;
}
